﻿

using Microsoft.AspNetCore.Components.Server.ProtectedBrowserStorage;
using Microsoft.JSInterop;

namespace SageKing.Blazor.OpenIdService.Components.Base;

public class ALayoutComponentBase : LayoutComponentBase, IAComponentBase<ALayoutComponentBase>
{

    // 初始化一个信号量，初始计数和最大计数均为 1，表示一次只允许一个线程进入
    public readonly SemaphoreSlim _asyncLock = new SemaphoreSlim(1, 1);
    public bool IsDisposed { get; set; } = false;

    #region 通用高参数

    /// <summary>
    ///  Header + Tab height
    /// 顶部偏移高度，默认 64 + 50 = 114
    /// </summary>
    public double TopOffset { get; set; } = (64 + 50);

    /// <summary>
    ///  分页组件高度
    /// </summary>
    public double PaginationHeight { get; set; } = 44;
    /// <summary>
    /// 滚动条高度
    /// </summary>
    public double ScrollBarHeight { get; set; } = 15;

    /// <summary>
    /// 通用工具栏高度
    /// </summary>
    public double IndexToolBarHeight { get; set; } = 36;

    /// <summary>
    /// 表格工具栏顶部高度
    /// </summary>
    public double TableToolBarHeight { get; set; } = 50;

    /// <summary>
    /// 分割条宽度
    /// </summary>
    public double SplitterWidth { get; set; } = 8;

    [CascadingParameter]
    public Error? Error { get; set; }
    #endregion

    #region 通用参数
    [Inject]
    public AntDesign.IMessageService Message { get; set; }

    [Inject]
    public IConfirmService ConfirmService { get; set; }

    [Inject]
    public ProtectedSessionStorage ProtectedSessionStore { get; set; }

    [Inject]
    public ILogger<ALayoutComponentBase> Logger { get; set; }

    [Inject]
    public NotificationService Notice { get; set; }

    [Inject]
    public IJSRuntime Js { get; set; }

    [Inject]
    public JsCommJsInterop JsCommModule { get; set; }

    [Inject]
    public NavigationManager NavigationManager { get; set; }
    #endregion

    #region copy

    public bool ShowManualCopy { get; set; }

    public async Task Clipboard(ElementReference btn, string copy)
    {
        await ((IAComponentBase<AComponentBase>)this).IClipboard(btn, copy);
    }
    #endregion

    #region 模板参数
    [Parameter]
    public virtual string TemplateName { get; set; }
    [Parameter]
    public virtual string TemplateType { get; set; }
    [Parameter]
    public virtual Dictionary<string, object> Properties { get; set; }
    #endregion
    
}
